const app=getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that=this;
    var userId = wx.getStorageSync('userId');

    that.getUser(userId);//读取会员
    that.get_qrcode(userId);
  },
  getUser: function (userId) {//读取会员
    var that = this;
    wx.request({
      url: app.globalData.apiUrl + 'user/getUser',
      data: {
        // opt: 'getUser',
        userId: userId,
      },
      header: {
        'content-type': 'application/json'
      },
      success: function (res) {
        if (res.data != null) {
          that.setData({
            user: res.data,
          })

        }
      }

    })
    // console.log(that.data.canIUse)
  },
  get_qrcode: function (userId) {//读取会员
    var that = this;
    wx.request({
      url: app.globalData.apiUrl + 'Qrcode/Index',
      data: {
        // opt: 'getUser',
        userId: userId,
        url: app.globalData.apiUrl
      },
      header: {
        'content-type': 'application/json'
      },
      success: function (res) {
        if (res.data != null) {
          console.log(res.data)
          that.setData({
            url:res.data.data
          })
        }
      }

    })
    console.log(that.data.url)
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
    
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    console.log(111)
    var that=this;
    return {
      title: "推荐",
      path: '/pages/register/register?code=' + that.data.user.Code + '&NickName=' + that.data.user.NickName,
    };
   
  }
})